#ifndef __PROTOCAL_H__
#define __PROTOCAL_H__

#define DATA_MAX_LEN 64

typedef struct
{
    uint8_t data[DATA_MAX_LEN];
    uint16_t len;
} msg_t;

typedef struct
{
    uint8_t head;
    uint8_t tail;
    uint8_t cnt;
    msg_t msg;
} data_queue_t;


typedef struct
{
    float longitude;
    float latitude;
    float altitude;
    uint8_t fix;
}location_t;

void protocal_init(void);
void protocal_collect_schedule(void);
bool protocal_queue_get_data(msg_t* pmsg);
void protocal_location_update(location_t* pLocation);
void protocal_rx_handle(uint8_t* data, uint8_t len);
void protocal_server_rx_handle(uint8_t* data, uint8_t len, uint8_t* resp, uint8_t* resplen);
void protocal_goto_sleep(void);
bool protocal_is_has_data(void);
bool protcal_is_logout(void);
uint16_t protocal_packet(uint8_t* device_id, uint8_t msg_id, uint8_t* data, uint8_t len, uint8_t* input)
#endif